﻿
@{
    ViewData["Title"] = "PersonalInformationEdit";
}

@section Scripts
    {
    <script type="text/javascript">
        var selfLayer = null, page = 1, active = null;
        layui.use(['layer', 'table', 'laydate', 'form'], function () {
            var form = layui.form;

            //监听提交
            form.on('submit(submit)', function (data) {
                var newPassword = $("#newPasswords").val();
                var Password = $("#Passwords").val();
                if (newPassword != Password) {
                    return alert("新密码输入不相同!");
                }
                console.log(localStorage.getItem('X-UserId'));

                //axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('X-TOKEN');
                //axios.defaults.headers.get['Content-Type'] = 'application/json';
                axios.get('/User/GetUserPasswordChange', {
                    params: {
                        oldPassword: $("#oldPasswords").val(),
                        password: $("#Passwords").val(),
                        userId: localStorage.getItem('X-UserId')
                    }
                }).then(function (response) {
                    console.log(response);
                    if (response.data.Code == 200) {
                        javascript: history.go(-1);
                    } else {
                        alert(response.data.msg)
                    }

                }).catch(function (error) {
                    console.log(error);
                });

                console.log(data);
                return false;
            });
        });
    </script>
}
<form class="layui-form layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">旧密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input w_545" autocomplete="off" lay-verify="required" id="oldPasswords">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input w_545" autocomplete="off" lay-verify="required" id="newPasswords">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码确认</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input w_545" autocomplete="off" lay-verify="required" id="Passwords">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <input class="layui-btn" type="button" style="width: 100px" lay-submit lay-filter="submit" value="立即提交" />
            <button type="reset" style="width: 100px" class="layui-btn layui-btn-primary">重置</button>
            <a style="width: 100px" class="layui-btn layui-btn-primary backIframe" asp-action="Index">返回</a>
        </div>
    </div>
</form>

